package com.zhangst.bbs.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.zhangst.bbs.domain.Cate;
import com.zhangst.bbs.service.CateServiceI;

@ParentPackage("basePackage")
@Namespace("/")
public class IndexAction {
	private CateServiceI cateService;
	
	
	
	public CateServiceI getCateService() {
		return cateService;
	}


	@Autowired
	public void setCateService(CateServiceI cateService) {
		this.cateService = cateService;
	}



	@Action(value="index", results = { @Result(name = "success", location = "/WEB-INF/page/index.jsp") })
	public String index(){
		List<Cate> cates = cateService.getCates();
		HttpServletRequest request = ServletActionContext.getRequest();
		request.setAttribute("cates", cates);
		return "success";
	}
}
